// System includes
//#include <unistd.h>      // For sleep
#include <pthread.h>
//#include <signal.h>
//#include <string.h>
#include <stdlib.h>

// Other includes
#include "CSocketClient.hpp"
#include "CArduinoClient.hpp"
//#include "CTrace.hpp"

void* socketClientThreadStart(void* data);

int main(int argc,char** argv)
{
   // Starting reader threads
   // Configuring dispacher
   {
      pthread_t socketClientThread;

      CArduinoClient arduinoClient;
      CSocketClient socketClient(1024, &arduinoClient);  // FIXME: remove hardcoded value
      arduinoClient.init(&socketClient);

      int socketClientThreadRet = pthread_create(&socketClientThread, NULL, socketClientThreadStart, reinterpret_cast<void*>(&socketClient));

      arduinoClient.start();

      pthread_join(socketClientThread, NULL);
   }
}

void* socketClientThreadStart(void* pData)
{
   if (0 != pData)
   {
      CSocketClient* pClient = reinterpret_cast<CSocketClient*>(pData);
      pClient->start();
   }
}
